<template>
  <div>
    <nav-bar title="我的礼包"/>
    <div class="content_scroll">
      <ul class="game_box">
        <li v-for="(item, index) in cardList" :key="index" class="game_list">
          <div class="game_content">
            <img :src="item.gameicon" alt="">
            <div class="game_info">
              <div class="game_name">{{item.gamename}}</div>
              <div class="game_type">
                <span>礼包码：</span>
                <span>{{item.card}}</span>
              </div>
              <div class="game_time">
                <span>领取时间：</span>
                <span>{{item.gettime | getYearDate}}</span>
              </div>
            </div>
          </div>
          <div class="game_detail" id="copy_text" @click="itemClick" :data-clipboard-text="item.card">复制</div>
        </li>
      </ul>
      <div v-if="cardList === null" class="none_img"></div>
    </div>
  </div>
</template>

<script>
import NavBar from '../../../components/common/navbar/NavBar.vue'
export default {
  components: {
    NavBar
  },
  data() {
    return {
      cardList: [],
    }
  },
  created () {
    this.getCardList();
  },
  methods: {
    getCardList() {
      this.axios.get('/mygame.json', {}).then(res => {
        this.cardList = res.data.list_card
      })
    },
    itemClick() {

    }
  },
  filters: {
    getYearDate(data) {
      var time = new Date(data * 1000) 
      var Y = time.getFullYear()
      var M = time.getMonth() + 1
      var D = time.getDate()
      return Y + '-' + M + '-' + D
    }
  }
}
</script>

<style lang="less" scoped>
.game_box {
  width: 9.146667rem;
  padding: .266667rem .426667rem;
}
.game_list {
  width: 9.146667rem;
  height: 2.533333rem;
  box-sizing: border-box;
  padding: .4rem .266667rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-radius: .266667rem;
  margin-bottom: .133333rem;
}

.game_content {
  display: flex;
  align-items: center;
}

.game_content img {
    width: 1.706667rem;
    height: 1.706667rem;
    margin-right: .266667rem;
}

.game_info {
  flex-grow: 1;
}

.game_name {
  font-size: .373333rem;
  font-weight: bold;
  color: #222222;
  line-height: .506667rem;
}

.game_type {
  font-size: .32rem;
  color: #808080;
  line-height: .32rem;
  margin-top: .2rem;
  width: 5.2rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.game_type span:last-child {
  color: #EA3323;
}

.game_time {
  font-size: .32rem;
  color: #808080;
  line-height: .32rem;
  margin-top: .106667rem;
}

.game_detail {
  flex-shrink: 1;
  width: 1.44rem;
  height: .613333rem;
  background: #ffffff;
  border: .013333rem solid #ff5543;
  border-radius: .306667rem;
  line-height: .613333rem;
  text-align: center;
  font-size: .32rem;
  color: #ff5543;
}

.dlg {
  font-size: .4rem;
  line-height: .8rem;
  padding: 0 .666667rem;
  background: rgba(0, 0, 0, 0.7);
  position: fixed;
  top: 50%;
  left: 50%;
  color: #fff;
  border-radius: .133333rem;
  transform: translate(-50%,-50%);
}

.none_img {
  width: 9.6rem;
  height: 3.466667rem;
  background: url('../../../assets/img/server/jy_none1.png') no-repeat;
  background-size: 100%;
  margin: 2.666667rem 0 0 .2rem;
}
</style>